/**
 * @author Ahammer
 * @date   2009 04
 * @update 2011 01 added 16 bit support
 */

/*
 * This file is part of Iqm.
 * Copyright (c) 2010-2011 Helmut Ahammer
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package opjai;
import javax.media.jai.JAI;
import javax.media.jai.OperationDescriptorImpl;
import javax.media.jai.OperationRegistry;
import javax.media.jai.registry.RIFRegistry;
import javax.media.jai.util.Range;


/**
 * This class defines the PointOpImage operator "IqmThreshold" for JAI
 * 
 */
public class IqmThresholdDescriptor extends OperationDescriptorImpl {
	
  private static final String[][] resources = {
      {"GlobalName",   "IqmThreshold"},
      {"LocalName",    "IqmThreshold"},
      {"Vendor",       "mug.qmnm"},
      {"Description",  "thresholds images"},
      {"DocURL",       "http://code.google.com/p/iqm/"},
      {"Version",      "1.0"},
      {"arg0Desc",   "color space options"}, 
      {"arg1Desc",   "band1 low threshold level"}, 
      {"arg2Desc",   "band1 high threshold level"}, 
      {"arg3Desc",   "band2 low threshold level"}, 
      {"arg4Desc",   "band2 high threshold level"}, 
      {"arg5Desc",   "band3 low threshold level"}, 
      {"arg6Desc",   "band3 high threshold level"}, 
      {"arg7Desc",   "link slider option"}, 
      {"arg8Desc",   "binarize option"}, 
      {"arg9Desc",   "lower threshold preset options"},
          
  };
  private static final String[] supportedModes   = {"rendered"};
  private static final int      numSources       = 1;
  private static final String[] paramNames       = {"Color",
	  												"ThresholdLow1", "ThresholdHigh1",
	  												"ThresholdLow2", "ThresholdHigh2",
	  												"ThresholdLow3", "ThresholdHigh3",
	  												"LinkSlider", "Binarize",
	  												"Preset"};
  private static final Class[]  paramClasses     = {Integer.class,
	  												Integer.class, Integer.class,
	  												Integer.class, Integer.class,
	  												Integer.class, Integer.class,
	  												Integer.class, Integer.class,
	  												Integer.class};
  private static final Object[] paramDefaults    = {0, //Grey
	  												0, 100, 
	  												0, 100, 
	  												0, 100,
	  												1, 0,
	  												0};   
  private static final Range[]  validParamValues = {new Range(Integer.class, 0,6), //Grey, RGB, HSV, HLS, CIELAB, CIELUV, XYZ 
	  												new Range(Integer.class, 0, Integer.MAX_VALUE), new Range(Integer.class, 0, Integer.MAX_VALUE),
	  												new Range(Integer.class, 0, Integer.MAX_VALUE), new Range(Integer.class, 0, Integer.MAX_VALUE),
	  												new Range(Integer.class, 0, Integer.MAX_VALUE), new Range(Integer.class, 0, Integer.MAX_VALUE),
	  												new Range(Integer.class, 0,1),   new Range(Integer.class, 0,1),
	  												new Range(Integer.class, 0,7)};
 
  
 /**
  * constructor: calls OperationDescriptorImpl
  */ 
  public IqmThresholdDescriptor() {
    super(resources, supportedModes, numSources, paramNames, paramClasses, paramDefaults, validParamValues);
  }

 /**
  * This method registers this method 
  */
  public static void register() {
      OperationRegistry opReg = JAI.getDefaultInstance().getOperationRegistry();   
      IqmThresholdDescriptor descriptor = new IqmThresholdDescriptor();
      opReg.registerDescriptor(descriptor);  
      IqmThresholdRIF rif = new IqmThresholdRIF();
      RIFRegistry.register(opReg, "iqmthreshold", "Iqm", rif);
   }
  
} //END
